1642B - Power Walking - CodeForces Solution


greedy *900

Please click on ads to support us..

Python Code:

for i in range(int(input())):
    a=int(input())
    l=list(map(int,input().split(' ')))
    b=len(set(l))
    for j in range(a):
        if j<b:
            print(b,end=" ")
        else:
            print(b+1,end=" ")
            b+=1

C++ Code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a, b, c, i, j, k, m, n, o, l, r, f = 0, cnt = 0, sum = 0, total = 0, mn = INT_MAX, mx = INT_MIN, sz, len, temp, pos, tc, x, y, z, arr[300010];
    vector<long long int> vrr;
    string s;

    cin>>tc;
    while(tc--)
    {
        cin>>n;
        set<int>st;
        for( i = 1; i <= n; i++ )
        {
            cin>>arr[i];
            st.insert(arr[i]);
        }
        a = st.size();

        for( i = 1; i<= n; i++ )
        {
            if( i <= a )
            {
                cout<< a << " ";
            }
            else cout<< i << " ";
        }

        cout<< endl;
    }



}


Comments

Submit
0 Comments
More Questions

109A - Lucky Sum of Digits
864C - Bus
626B - Cards
1221A - 2048 Game
1374D - Zero Remainder Array
1567C - Carrying Conundrum
1029C - Maximal Intersection
922C - Cave Painting
811C - Vladik and Memorable Trip
1589C - Two Arrays
1510K - King's Task
126B - Password
462A - Appleman and Easy Task
839C - Journey
622A - Infinite Sequence
659C - Tanya and Toys
1266A - Competitive Programmer
234C - Weather
1332C - K-Complete Word
525C - Ilya and Sticks
1555C - Coin Rows
1324C - Frog Jumps
715A - Plus and Square Root
774D - Lie or Truth
1186D - Vus the Cossack and Numbers
505B - Mr Kitayuta's Colorful Graph
1324D - Pair of Topics
157B - Trace
34C - Page Numbers
279A - Point on Spiral